home *** CD-ROM | disk | FTP | other *** search
/ Programmers Heaven 2 / Programmers Heaven 2.iso / files / graphics / library / wgt51_r2.zip / WGT5 / EXAMPLES / WGT07.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-03  |  2.6 KB  |  84 lines

  1. /*
  2. ==============================================================================
  3.                       WordUp Graphics Toolkit Version 5.0                     
  4.                              Demonstration Program 7                          
  5.                                                                               
  6.  Displays some text with the text grid off until you hit a key, then turns    
  7.  the grid on and displays text, to show the difference.                       
  8.                                                                               
  9.  *** PROJECT ***                                                             
  10.  This program requires the file WGT5_WC.LIB to be linked.
  11.                                                                               
  12.  *** DATA FILES ***                                                          
  13.  NONE                                                                        
  14.                                                            WATCOM C++ VERSION 
  15. ==============================================================================
  16. */
  17.  
  18. #include <wgt5.h>
  19.  
  20.  
  21. void main(void)
  22. {
  23.   short x;
  24.   short y;
  25.   short col;
  26.   short oldmode;
  27.   color palette[255];
  28.  
  29.   printf ("WGT Example #7\n\n");
  30.   printf ("This program will randomly paste a text string onto the screen without using\n");
  31.   printf ("a text grid coordinate system. Press a key to see how it would look by\n");
  32.   printf ("using a grid. A second keypress ends the program.\n");
  33.   printf ("\n\nPress any key to continue.\n");
  34.   getch ();
  35.  
  36.   if ( !vgadetected() )
  37.   {
  38.     printf("Error - VGA card required for any WGT program.\n");
  39.     exit (0);
  40.   }
  41.  
  42.   oldmode = wgetmode ();
  43.   vga256 ();
  44.  
  45.   /* Set our palette */
  46.   for (y = 0; y < 64; y++)
  47.     wsetrgb (y, y, y, y, palette);
  48.   for (y = 0; y < 64; y++)
  49.     wsetrgb(y + 64, y, 0, 0, palette);
  50.   for (y = 0; y < 64; y++)
  51.     wsetrgb(y + 128, 0, y, 0, palette);
  52.   for (y = 0; y < 64; y++)
  53.     wsetrgb(y + 192, 0, 0, y, palette);
  54.   wsetpalette (0, 255, palette);
  55.  
  56.   wcls (0);
  57.  
  58.   wtextgrid (TEXTGRID_OFF);
  59.   wtexttransparent (TEXTFGBG);   /* Turn foreground and background on */
  60.  
  61.   do {
  62.     x = rand () % 320;
  63.     y = rand () % 200;
  64.     col = rand () % 256;
  65.     wtextcolor (col);
  66.     wouttextxy (x, y, NULL, "WordUp Graphics Toolkit");
  67.   } while (!kbhit ());
  68.   getch ();
  69.  
  70.   wcls (0);
  71.   wtextgrid (TEXTGRID_ON);
  72.   do {
  73.     x = rand () % 80;
  74.     y = rand () % 25;
  75.     col = rand () % 256;
  76.     wtextcolor (col);
  77.     wtextbackground (rand () % 256);
  78.     wouttextxy (x, y, NULL, "WordUp Graphics Toolkit");
  79.   } while (!kbhit ());
  80.  
  81.   getch ();
  82.   wsetmode (oldmode);
  83. }
  84.